<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>vue事件修饰符</title>
		
	</head>
	<body>
		<div id="app">
			<div @click="addNum2">
				<h3>{{num}}</h3>
				<button @click.stop="addNum">自减1</button>
			</div>
			<!-- 事件冒泡：如果事件有 嵌套关系,执行完内部与事件之后，
			执行外部事件，这种现象称为事件冒泡 
			.stop阻止事件冒泡
			语法：
				v-on:click.stop =
				@click.stop-->
			<!-- 阻止默认行为 
			阻止a标签的默认行为加.prevent-->
			<hr>
			<div>
				<h3>阻止默认行为</h3>
				<a href="https://www.baidu.com" @click.prevent="baidu">百度</a>
			</div>
			<div>
				<h3>特殊按键字符</h3>
				<!-- 用户按回车键触发事件函数 -->
				回车键触发:<input name = "username" type ="text" v-on:keyup.enter="handler"/><br>
				 删除键触发:<input name = "username" type = "text" @keyup.delete="handler"/>
				 space键触发:<input name = "sex" type = "text" @keyup.space="handler"/>
				 tab键触发:<input name = "sex" type="text"  @keydown="handler"/>
			</div>
		</div>
		<script src="../js/vue.js"></script>
		<script>
		const app = new Vue({
			el:"#app",
			data:{
				num:1
			},	
			methods: {
				addNum(){
					this.num--
				},
				addNum2(){
					this.num*=2
				},
				baidu(){
					console.log("点击百度按钮")
				},
				handler(){
					console.log("函数被执行")
				}
				
			
			}
		})
	</script>
	</body>
</html>
